﻿@model Tippelde.Services.Dtos.EventWithBetData

<tr class="event-container" id="event-container-row-@Model.Id">
    <td class="event-short-description">
        <span title="@Model.Name">@Model.ShortName</span>
    </td>
    <td class="event-home-team-logo event-team-logo team-logo">
        <img src="@Model.HomeTeam.LogoUrl" />
    </td>
    <td class="event-home-team-name event-team-name">
        <span>@Model.HomeTeam.Name</span>
    </td>
    <td class="event-status-container">
        @if (!Model.HasResult)
        {
            <span>@String.Format("{0:yyyy-MM-dd}", Model.EventDate)</span>
            <br />
            <span>@String.Format("{0:H:mm}", Model.EventDate)</span>
        }
        else
        {
            <span>@Model.Result.HomeResult</span>
            <span>-</span>
            <span>@Model.Result.AwayResult</span>
        }
    </td>

    <td class="event-away-team-name event-team-name">
        <span>@Model.AwayTeam.Name</span>
    </td>
    <td class="event-away-team-logo event-team-logo team-logo">
        <img src="@Model.AwayTeam.LogoUrl" />
    </td>
    <td class="event-options">
        @if (Model.IsUserEditor)
        {

            <a href='@Url.Action("Edit", "Event", new { Id = @Model.Id })' class="">
                <span class="glyphicon glyphicon-edit" title="Szerkesztés"></span>
            </a>
            <span>
                @using (Html.BeginForm("Delete", "Event", FormMethod.Post, new { @class = "form-action-delete inline-submit-form" }))
                {
                    @Html.AntiForgeryToken()
                    @Html.Hidden("Id", Model.Id)
                    <button class='btn btn-link' type="submit" title="Törlés">
                        <span class='glyphicon glyphicon-remove'></span>
                    </button>
                }
            </span>
        }
    </td>
</tr>
@{
    string betResultClass = String.Empty;
    switch (Model.BetResultStatus)
    {
        case Tippelde.Entities.BetResultStatus.Failed:
            betResultClass = "danger";
            break;
        case Tippelde.Entities.BetResultStatus.SuccessPartial:
            betResultClass = "warning";
            break;
        case Tippelde.Entities.BetResultStatus.SuccessComplete:
            betResultClass = "success";
            break;
        default:
            break;
    }
    if (!Model.HasBet && !Model.IsBetInterval && String.IsNullOrWhiteSpace(betResultClass))
    {
        betResultClass = "hidden";
    }
}
<tr class="bet-container @betResultClass" id="bet-container-row-@Model.Id">
    <td colspan="7">
        @{ Html.RenderPartial("_BetForEvent", Model); }
    </td>
</tr>
@if (Model.IsUserEditor && Model.HasResult || (!Model.HasResult && Model.EventDate < DateTime.Now))
{
    <tr class="result-add-container" id="result-container-row-@Model.Id">
        <td colspan="7">
            @{ Html.RenderPartial("_ResultForEvent", Model); }
        </td>
    </tr>
}